#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
	int b, c, d;
	double a;
	scanf("%lf %d %d %d", &a, &b, &c, &d);
	if (b == 11 && c == 11)
	{
		a = a * 0.7;
	}
	else if (b == 12 && c == 12)
	{
		a = a * 0.8;
	}
	if (d == 1)
	{
		a = a - 50;
	}
	if (a < 0)
	{
		a = 0;
	}
	printf("%.2lf", a);

	return 0;
}